
let obj = {
    name: 'ljp',
    add(a, b) {
        console.log(this.name, a, b)
    }
}

const obj1 = {
    name: 'xxx'
}

obj.add(1, 2)

let fn = obj.add.bind(obj1, 1, 2)

fn()

Function.prototype.myBind = function (ctx, ...args) {
    let fn = this
    return function () {
        return fn.call(ctx, ...args)
    }
}


let res = obj.add.myBind(obj1, 1, 2)

res()

/***
 *  bind 与 call 和apply 相似
 *  返回的是个函数  
 *  需要手动调用才会触发
 */